package com.blb.community.controller;

import com.blb.community.pojo.ResponseResult;
import com.blb.community.pojo.ZyComplaintSuggest;
import com.blb.community.service.IZyComplaintSuggestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 投诉建议  前端控制器
 * </p>
 *
 * @author gch
 * @since 2023-12-05
 */
@CrossOrigin
@RestController
public class ZyComplaintSuggestController {

    @Autowired
    private IZyComplaintSuggestService zyComplaintSuggestService;

    @PutMapping("/suggest")
    public ResponseResult<String> add(@RequestBody ZyComplaintSuggest zyComplaintSuggest) {
        zyComplaintSuggestService.addComplaintSuggest(zyComplaintSuggest);
        return ResponseResult.ok("ok");
    }

    @PostMapping("/suggest-userId")
    public ResponseResult<List<ZyComplaintSuggest>> getListByUserId(@RequestBody Long userId) {
        List<ZyComplaintSuggest> list = zyComplaintSuggestService.findComplaintSuggestByUserId(userId);
        return ResponseResult.ok(list);
    }

    @DeleteMapping("/suggest/{id}")
    public ResponseResult<String> delete(@PathVariable Long id) {
        zyComplaintSuggestService.removeById(id);
        return ResponseResult.ok("ok");
    }
}
